#include "PoseHandler.hpp"
namespace adas
{
    PoseHandler::PoseHandler(const Pose& pose) noexcept : pose(pose){}//初始化方式规范
    void PoseHandler::Move() noexcept//前进函数实例化
    {
        if (pose.heading == 'E') {
            ++pose.x;
        } else if (pose.heading == 'W') {
            --pose.x;
        } else if (pose.heading == 'N') {
            ++pose.y;
        } else if (pose.heading == 'S') {
            --pose.y;
        }
    }
    void PoseHandler::TurnLeft() noexcept//左转函数实例化
    {
        if (pose.heading == 'E') {
            pose.heading = 'N';
        } else if (pose.heading == 'N') {
            pose.heading = 'W';
        } else if (pose.heading == 'W') {
            pose.heading = 'S';
        } else if (pose.heading == 'S') {
            pose.heading = 'E';
        }
    }
    void PoseHandler::TurnRight() noexcept//右转函数实例化
    {
        if (pose.heading == 'E') {
            pose.heading = 'S';
        } else if (pose.heading == 'S') {
            pose.heading = 'W';
        } else if (pose.heading == 'W') {
            pose.heading = 'N';
        } else if (pose.heading == 'N') {
            pose.heading = 'E';
        }
    }
    void PoseHandler::Backward(void) noexcept//后退函数实例化
    {
        if (pose.heading == 'E') {
            --pose.x;
        } else if (pose.heading == 'W') {
            ++pose.x;
        } else if (pose.heading == 'N') {
            --pose.y;
        } else if (pose.heading == 'S') {
            ++pose.y;
        }
    }
    Pose PoseHandler::Query() const noexcept//读取函数实例化
    {
        return pose;
    }
    void PoseHandler::Fast() noexcept//加速函数实例化
    {
        fast = !fast;
    }
    void PoseHandler::Reverse() noexcept//后退函数实例化
    {
        reverse = !reverse;
    }
    void PoseHandler::Bus() noexcept//（公交车/跑车）函数实例化
    {
        bus = !bus;
    }
    bool PoseHandler::IsFast() const noexcept//加速判断函数实例化
    {
        return fast;
    }
    bool PoseHandler::IsReverse() const noexcept//后退判断函数实例化
    {
        return reverse;
    }
    bool PoseHandler::IsBus() const noexcept//（公交车/跑车）判断函数实例化
    {
        return bus;
    }
} 